package com.yanqu.road.logic.activity.hotpotjump.game.choose;

import com.yanqu.road.entity.autodata.hotpotjump.HotpotJumpGrid;
import com.yanqu.road.entity.autodata.hotpotjump.HotpotJumpUnit;
import com.yanqu.road.logic.activity.hotpotjump.game.JumpBoardGrid;
import com.yanqu.road.logic.activity.hotpotjump.game.eJumpDirection;

import java.util.ArrayList;
import java.util.List;

/**
 * 8 随机怪物所在点 排除死亡怪物
 */
public class HotpotJumpSkillChoose8 extends HotpotJumpSkillChoose {
    @Override
    public List<List<JumpBoardGrid>> chooseGrid() {
        List<List<JumpBoardGrid>> result = new ArrayList<>();

        List<JumpBoardGrid> allGrids = new ArrayList<>();
        for (HotpotJumpUnit unit : gameLogic.getGameData().getUnits()) {
            if (unit.isDead()) {
                continue;
            }
            JumpBoardGrid boardGrid = gameLogic.findBoardGridByJumpGrid(unit.getHeadPos());
            allGrids.add(boardGrid);
            if (!gameLogic.getConfig().isBoss3(unit.getConfigId())) {
                for (HotpotJumpGrid bodyPo : unit.getBodyPos()) {
                    JumpBoardGrid bodyBoardGrid = gameLogic.findBoardGridByJumpGrid(bodyPo);
                    if (bodyBoardGrid != null) {
                        allGrids.add(bodyBoardGrid);
                    }
                }
            }
        }

        int randomNum = skillRange.getRangeNum();
        List<JumpBoardGrid> chooseGrids = gameLogic.randomHelper.getRandomList(allGrids, randomNum);

        for (JumpBoardGrid grid : chooseGrids) {
            List<JumpBoardGrid> grids = gameLogic.calcRangeGrids(grid, skillRange, eJumpDirection.None);
            result.add(grids);
        }

        return result;
    }
}
